﻿@model IEnumerable<Stardust.Models.ServiciosBean>

@{
    ViewBag.Title = "Buscar Servicio";
}

<h2>BuscarServicio</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm("BuscarServicio","Servicios", FormMethod.Post, new { @class = "form" }))

{

    <fieldset>
        <div class = "widget" >
            <div class = "title"><h6>Buscar Servicio</h6></div>           

            <div class="formRow">
                <label>Nombre</label>
                <div class = "formRight" ><input type = "text" id = "nombre" name = "nombre" /></div>
                <div class = "clear" ></div>
            </div>
        </div>
    </fieldset>
    <p>
        <input type="submit" value="Buscar" class = "redB" />
    </p>


}

<p></p><p></p>

@if (ViewBag.estado != 0)
{ 
<div class="wrapper">
    <div class="widget">
      <div class="title">
      <h6>Lista de Servicios</h6>
      </div>
      <div class="dataTables_wrapper">            
            <table cellpadding = "0" cellspacing = "0" width = "100%" class = "display dTable">

    <thead>
        <tr>
            <th class="ui-state-default" rowspan="1" colspan="1" style="width:60px;" >
                <div class="DataTables_sort_wrapper">
                ID
                <span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span>
                </div>
             </th>

             <th class="ui-state-default" rowspan="1" colspan="1" style="width:100px;" >
                <div class="DataTables_sort_wrapper">
                Nombre
                <span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span>
                </div>
             </th>

             <th class="ui-state-default" rowspan="1" colspan="1" style="width:200px;" >
                <div class="DataTables_sort_wrapper">
                Descripcion
                <span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span>
                </div>
             </th>

              <th class="ui-state-default" rowspan="1" colspan="1" style="width:200px;" >
                <div class="DataTables_sort_wrapper">
                Uso
                <span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span>
                </div>
             </th>

             
            <th class="ui-state-default" rowspan="1" colspan="1">
            
             </th>
        </tr>
    </thead>
    <tbody>

    @foreach (var item in Model) {
            <tr class="gradeA odd">
                <td>
                    @Html.DisplayFor(modelItem => item.id)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.nombre)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.descripcion)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.estado2)
                </td>
                
                <td>
                   <a href="@Url.Action("ModificarServicio", new { id = item.id })"><img src="../../Content/images/icons/color/pencil.png", alt="Edit" />Modificar</a>  |                      
                   <a href="@Url.Action("DetallesServicio", new { id = item.id })"><img src="../../Content/images/icons/color/edit-column.png", alt="Details" />Detalles</a> |  

                <a  id = @item.id class = "eliminar" href=""><img src="../../Content/images/icons/color/cross.png", alt="Delete" />Borrar</a>

                    @*@Html.ActionLink("Eliminar", "EliminarServicio", new { id = item.id }) <img src="../../Content/images/icons/color/cross.png" />   *@                 
                </td>
            </tr>
    }
    
    <div id="dialogEliminar" title="Desea Eliminar el Servicio?">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
    El Servicio que UD. Elimine ya no podra ser recuperado</p>
    </div>
    </tbody>

        </table>
      </div>
        
    </div>
</div>
}

<script type = "text/javascript">
    var idEliminar = 0;
    $(".eliminar").click(function () {
        
        $('#dialogEliminar').dialog('open');
        idEliminar = $(this).attr("id");
        return false;
    });

    $('#dialogEliminar').dialog({
        autoOpen: false,
        resizable: false,
        draggable: false,
        width: 300,
        modal: true,
        title: "!Confirmar Eliminacion de Servicio",
        position: "center",
        buttons: {
            "Aceptar": function () {
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    url: "Delete/" + idEliminar,
                    success: function (data) {
                        oTable.fnDraw(false);
                        if (data.me == "") {
                            $(this).dialog("close");
                            location.reload();
                        }
                    }
                });

            },
            "Cancelar": function () {
                $(this).dialog("close");
                return false;
            }
        }
    });

</script>